package business;

import java.util.Iterator;
import java.util.Map;
import java.util.Set;

import javax.servlet.http.HttpServletRequest;

import service.myservice.panduan.PanduanService;
import service.myservice.panduan.PanduanServiceImpl;
import service.vo.MessageVo;
import struts.action.Action;
import struts.form.ActionForm;

public class PanduanAction implements Action{

	public String exeute1(HttpServletRequest request) {
		String url = "";
		PanduanService panduanService = new PanduanServiceImpl();
		Map<String, MessageVo> map = panduanService.getVO(request.getParameter("text"));
		Set<String> set = map.keySet();
		for(Iterator<String> it = set.iterator(); it.hasNext();){
			url = it.next();
			request.setAttribute("mess", map.get(url));
		}
		return url;
	}


	@Override
	public String exeute(HttpServletRequest request, ActionForm form, Map<String, String> formForward) {
		String url = "";
		PanduanForm panduanForm = (PanduanForm)form;
		PanduanService  service = new PanduanServiceImpl();
		Map<String, MessageVo> map = service.getVO(panduanForm.getName());
		Set<String> set = map.keySet();
		for(Iterator<String> it = set.iterator(); it.hasNext();) {
			url = it.next();
			request.setAttribute("mess", map.get(url));
		}
		return formForward.get(url);
	}}
